<?php

/**
* fetch the warehouse
*/
$CLFetchers->fetchLstDataHeader($Db,
                                $jobId,
                                $SourceDb,
                                $nHeader,
                                $lstHeader);

$srcWhs   = $lstHeader["WAREHOUSE"][0];
$srcDbWhs = "WHS_" . $srcWhs;

$CFetchers->fetchLstDataDetail($Db,
                               $jobId,
                               $SourceDb->fetchValue("srcDbDtl"),
                               $nDetail,
                               $lstDetail);

if($isApprove){

  /**
   * allocate the inventory
   */
  $CHandlers->insToWhsBalance($Db,
                              $lstHeader["MODEL_ID"][0],
                              $lstHeader["UNIT"][0],
                              $lstHeader["QTY"][0],
                              $srcDbWhs);
}else{

  /**
   * deallocate the inventory
   */
  $qty = $lstHeader["QTY"][0] * -1;

  $CHandlers->insToWhsBalance($Db,
                              $lstHeader["MODEL_ID"][0],
                              $lstHeader["UNIT"][0],
                              $qty,
                              $srcDbWhs);
}
?>